﻿using System.Windows.Input;

namespace _03_View_Model_MVVM_Basics.Directory
{
	public class RelayCommand : ICommand
	{
		public event EventHandler? CanExecuteChanged;
		private Action _action;

		public RelayCommand(Action action)
		{
			_action = action;
		}

		public bool CanExecute(object? parameter)
		{
			return true;
		}

		public void Execute(object? parameter)
		{
			if (_action == null) return;
			_action();
		}
	}
}
